home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: String Problem
- Date: Wed, 27 Mar 96 00:52:53 GMT
- Organization: none
- Distribution: world
- Message-ID: <827887973snz@genesis.demon.co.uk>
- References: <4j6l61$4no@B1FF.mindspring.com> <tsw-2503961721130001@cypher.3do.com>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <tsw-2503961721130001@cypher.3do.com> tsw@3do.com "Tom Watson" writes:
-
- >In article <4j6l61$4no@B1FF.mindspring.com>, vtipres@atl.mindspring.com wrote:
- >
- >> This is supposed to be a variation on sample code from a textbook.
- >> Can anyone tell me why NameCheck = 0 when I run the program?
- >>
- >> /*
- >> Testing character transactions.
- >> */
- >>
- >> #include <stdio.h>
- >> #include <ctype.h>
- >>
- >> int main()
- >> {
- >> char Name[11] = "John";
- >
- >You have initialized a local variable to the text "John" (with a trailing
- >'nul' character. After that (the first 5 locations in the array) the data
- >is undefined.
-
- Nothing is undefined - you either initialise a whole object or none of it.
- Trailing elements/members are initialised to zero.
-
- >The variable 'WhereName' is a pointer, and should not be printed with a
- >'%i' formatting specification. Pointers can be different sizes than ints
- >(I use a compiler that this is the case!). It should be printed with a
- >'%p' specification if you want to see what it is.
-
- But make sure you cast the corresponding argument to void * if it doesn't
- already have that type.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-